#include<stdio.h>
#include<String.h>
int(nain(){
FILE *p;
int falg = 0,len,i=0,j=0;//
char *rwtab[27]={,,,,>"main","if","then","while”，"do".
"static","int","double","struct","break","else","long",
"switch","case","typedefn,"char","return",Hconst",nfloat", "short” /'continue", "for", "void”，,,sizeof", "default", ”do"} ;//2 砰
char str[1000],strl[1000],c;
int syn,num; int k;
char token[200];

if(Cp=fopen(',e:\\testl.txt,,,,,rt,,))=NULL){
printf®法打开”）；
return 0;
}

//fgets(str,1000,p);
while((c=getc(p))!=EOF){
str[i++] = c;
}
fclose(p);
ifC(p=fopenC'e:\\test2.txt',,"w,,))=NULL){
printf®法打开”）；
return 0;
}
str[i] = '\0';
//printf C*%s\n", str);
forCi=0；str[i]!=,\0,;){
j = 0；
num = -1;


//2ye
while((str[i]>=,a*&&str[i]<=,z,)lI(str[i]>=,A,&&str[i]<=,Z')ll(str[i]>=,0,&&strLi]<=,9,)l
token[j++] = str[i++];
token[j] = '\0f; for( k=l;k<27;k++){
     if(strcmp(rwtab[k] ,token)=0)
     break;
     if(k<25)
        syn = k;
    else if(k=25)
        syn = 39;
    else if(k=26)   
        syn = 40;   
    else syn = 25;
    }//关键字和标示符处理
    else if(str[i]>=,0*&&str[i]<='9,){
num = 0;
while(str[i]x0&&str[i]<=9){//当读到第一个为0~9的数字时接着读之后的数字
num = num*10+str[i]-,0,;
token[j++] = str[i++];
}
if((str[i]>=,a,&&str[i]<=,z,)lI (str[i]>=,A'&&str[i]<='Z,))
{
num=-l;syn=-3;
while((str[i]>=,a,&&str[i]<='z')lI (str[i]>=,A'&&str[i]<='Z,)ll(str[i]>='0,&&str[i]<=,9,)){ token[j++] = str[i++];
else syn = 26;
}//数字在此处处理
else {
    72	: ,&&str[i+l]=, = '){



//3ye
syn = 32;	I
token[j++] = str[i];	
token[j++] = str[++i];	
i++;	
	
else if(str[i]=,<,&&str[i+l]=	
syn = 34;	
token[j++] = str[i];	
token[j++] = str[++i];	
i++;	
	
else if(str[i]=,<,&&str[i+l]=	
syn = 35;	
token[j++] = str[i];	
token[j++] = str[++i];	
i++;	
	
else if(str[i]=,>'&&str[i+l]=	
syn = 36;	
token[j++] = str[i];	
token[j++] = str[++i];	
i++;	
}	
else	'){	
i++;	
syn = -2;	
}/從格处理	
/*	
else	'){	
syn = -1;	
while(str[i++]!=' '){	
token[j++] = str[i];	
}	
}/久明字符的处理	
*/	
else{	
switch(str[i]){	
case '+*: syn = 27;break;	
case : syn = 28;break;	
case	syn = 29;break;	
case '/*: syn = 30;break;	

//4ye
case '::	:syn = 31;break;
case 'v‘:	:syn = 33;break;
case	:syn = 36;break;
case ';':	:syn = 41;break;
case ')，:	:syn = 4^;break;
case	:syn = 42;break;
case	:syn = 0;break;
case	:syn = 38;break;
default:	syn = -Ijbreak;
}	
	
token[j++~	1 = str[i++];
}	
}	
tokenQj]='	\0';
if(num!=-l)i	■
printfC'%d	%d\nH,num,syn);
	
	
	
}	
else if(syn!=-l&&syn !=-2 &&syn!=-3){
printf(u%s	%d\n",token,syn);
	
}	
else if(syn=	=-l){
printf(u%s	error\n",token);
	
}	
else if(syn	==-3){
printf(u%s	error ID\n",token);
	
}	
}	
fclose(p);	
return 0;	
}	